#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
. "$(dirname -- "$0")/log.sh"
# . "$(dirname -- "$0")/valid-checkout.sh"


info "开始检查暂存区代码是否存在未解决冲突的代码..."

for FILE in $(git diff --name-only --cached --)
do
    # 过滤掉 pre-commit 文件
    if [ "$FILE" = ".husky/pre-commit" ]; then
        continue
    fi
    # 匹配 <<<<<<< HEAD
    if grep "<<<<<<< HEAD" "$FILE";
    then 
        error "$FILE 存在 未解决冲突的代码，请解决以上所在行的冲突后再提交！"
        exit 1
    fi
done
info "开始Eslint、Prettier检查..."

# npx lint-staged

success "恭喜你，检测通过！"
exit